package com.information.manage.basic.audit.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.information.manage.basic.audit.model.dto.InitAuditTaskDataDto;
import com.information.manage.basic.audit.model.entity.AuditFeedDo;
import com.information.manage.basic.audit.model.entity.AuditModelDO;
import com.information.manage.basic.audit.model.entity.AuditTaskDO;
import com.information.manage.basic.audit.model.entity.AuditTaskLevelDO;
import com.information.manage.basic.audit.model.query.AuditCurrentTasksQuery;
import com.information.manage.basic.audit.model.query.FindAuditTaskQuery;
import com.information.manage.basic.common.result.Result;
import com.information.manage.basic.model.entity.SysUserDO;
import com.information.manage.basic.model.vo.LoginUserInfoVO;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.atomic.AtomicInteger;

public interface AuditTaskService extends IService<AuditTaskDO> {

    /**
     * 初始化审核任务
     */
    void initAuditTask(AuditModelDO auditModelDO, InitAuditTaskDataDto initAuditTaskDataDto, LoginUserInfoVO userInfo);

    /**
     * 处理审核通过后的审核任务流程执行
     *
     * @param auditTaskDO          审核任务
     * @param currentAuditTaskLevelDO 当前审核任务层级
     */
    void handlePassAuditTaskProcess(AuditTaskDO auditTaskDO, AuditTaskLevelDO currentAuditTaskLevelDO);

    /**
     * 查询审核任务列表
     *
     * @param findAuditTaskQuery
     * @return
     */
    Result auditTasksPage(HttpServletRequest request, FindAuditTaskQuery findAuditTaskQuery);

    /**
     * 撤销属于审核中的任务
     */
    void cancelProcessAuditTasks(String mainId);

    /**
     * 审批当前任务
     *
     * @param auditCurrentTasksQuery
     */
    Result examineTask(HttpServletRequest request, AuditCurrentTasksQuery auditCurrentTasksQuery);

    void executeApprove(AuditTaskLevelDO auditTaskLevelDO, LoginUserInfoVO userInfo, AuditCurrentTasksQuery auditCurrentTasksQuery, AtomicInteger successCount, AtomicInteger failCount);

    void lockTaskAndApprove(AuditTaskLevelDO auditTaskLevelDO, LoginUserInfoVO userInfo, AuditCurrentTasksQuery auditCurrentTasksQuery);

    Result getAuditFeedByAuditTaskId(Integer auditTaskId);
}
